//
//  LoveDetailCell.swift
//  Spookiness
//
//  Created by 腾億 on 2017/12/15.
//  Copyright © 2017年 tml. All rights reserved.
//

import UIKit

class LoveDetailCell: UICollectionViewCell {
    fileprivate lazy var iconView: UIImageView = {
        let imageView = UIImageView()
        imageView.contentMode = .scaleAspectFill
        imageView.clipsToBounds = true
        return imageView
    }()
    
    fileprivate lazy var titleLB: UILabel = {
        let title = UILabel()
        title.textColor = UIColor.black
        title.font = UIFont.systemFont(ofSize: 14)
        return title
    }()
    
    fileprivate func setUpSnap() {
        self.titleLB.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview().inset(UIEdgeInsetsMake(0, 10, 0, 10))
            make.height.equalTo(25)
            make.bottom.equalToSuperview().offset(-10)
        }
        
        self.iconView.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.bottom.equalTo(self.titleLB.snp.top)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(self.iconView)
        self.contentView.addSubview(self.titleLB)
        setUpSnap()
        
    }
    
    var model: LoveComicsModel? {
        didSet{
            guard let model = model else {
                return
            }
            self.iconView.kf.setImage(urlString: model.cover, placeholder: #imageLiteral(resourceName: "normal_placeholder_v"))
            self.titleLB.text = model.name
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
